Network Object Linking
A
Architecture
The
An object linker can contain
The
Users can use any linkers in the tree, but the Persistence System directly starts from the GNOL to retrieve the objects.
Here is an architecture diagram example of the GNOL tree.
Their roles in the persistence system.
The Framework's Persistence System is autonomous enough to support
In fact, the real first interest in a
Second interest is when you have a certain data structure (let's say a database) and wants it to be used in the GNOL.
Implementation
In this part, we'll take a look at how to implement a Network Object Linker.
Here is the Network Object Linker UML diagram:
As you can see, an Object Linker is also a presence handler for its registered references.
If you ever tried to implement the NetworkObjectLinker
you must have been surprised to see that you had to implement
getPresence(R)
and isPresentOnEngine(String, R)
. Which must have confused you because you don't know how to handle your references presences.
AbstractNetworkPresenceHandler
Any implementation of the NetworkObjectLinker
trait should also extend the AbstractNetworkPresenceHandler
* abstract class
that will implement all the presence handling and let you implement the findObject(R)
method.
class DatabaseLinker(omc: ObjectManagementChannel, db: Connection) extends AbstractNetworkPresenceHandler[DatabaseObjectReference](omc, null) with NetworkObjectLinker[DatabaseObjectReference] {
override def findObject(ref: DatabaseObjectReference): Option[NetworkObject[_ <: DatabaseObjectReference] = {
//use the database connection to retrieve the object
}
}
By extending this class you'll find out that its constructor needs an ObjectManagementChannel
and a nullable parent linker.
If your linker is a root linker, parent must be null. the ObjectManagementChannel
is initially accessible only when
supplying a root linker to the GNOL.
Register the linker in the GNOL
val linker: DatabaseLinker = gnol.addRootLinker(omc => new DatabaseLinker(omc))
linker.findObject(DatabaseObjectReference(...)) match {
case Some(X) => ...
case None => ...
}